#include <getopt.h>
#include <unistd.h>
#include <fcntl.h>
#include "kw.h"
#include "vty.h"
#include "profile.h"
#include "builtin.h"

int cli_exit(void)
{
  vty_exit();
  return 0;
}

int cli_init(const char *prompt, const char *profile)
{
  setbuf(stdout, NULL);
  init_kw();
  set_progname(prompt);
  init_builtin();
	init_profile(profile);
  vty_init(VTY_OPT_CBREAK|VTY_OPT_PROMPT);
  return 0;
}

void cli_in_event(void *userdata)
{
  char buf[LINEBUF_MAX]; 
  int size = read(STDIN_FILENO, buf, LINEBUF_MAX - 1);
  if (size > 0) {
    buf[size] = 0;
    vty_read(buf, size);
  }
}







